Build a “quadmesh”" in R.
library(quadmesh)
library(raster)## Loading required package: sp
library(rglwidget)## Warning in rgl.init(initValue, onlyNULL): RGL: unable to open X11 display
## Warning: 'rgl_init' failed, running with rgl.useNULL = TRUE
## The functions in the rglwidget package have been moved to rgl.
data(volcano)
r <- setExtent(raster(volcano), extent(0, 100, 0, 200))
qm <- quadmesh(r)
library(rgl)##
## Attaching package: 'rgl'
## The following objects are masked from 'package:rglwidget':
##
## playwidget, rglwidget
scl <- function(x) (x - min(x))/diff(range(x))
shade3d(qm, col = grey(scl(qm$vb[3,qm$ib])))
subid <- currentSubscene3d()
rglwidget(elementId="quadmesh001")A “quadmesh” is a dense mesh describing a topologically continuous surface of 4-corner primitives. I.e. a grid, without the “regular”. This is useful particularly when combined with map projections and texture mapping.
We are not limited to a regular grid, trivially let’s distort the mesh by a weird scaling factor.
The topology of the grid is still sound, but we are no longer bound to the regular constraint.
qm <- quadmesh(r)
qm$vb[1,] <- qm$vb[1,] * qm$vb[2,]/54
open3d()## null
## 2
shade3d(qm, col = grey(scl(qm$vb[3,qm$ib])))
subid <- currentSubscene3d()
rglwidget(elementId="quadmesh002")